package com.zrc.superframe_net.common.net

import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.ObservableTransformer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * @Author: superman
 * @CreateTime: 6/27/21
 * @Describe:
 */
class ApplySchedulers<T> : ObservableTransformer<T, T> {
    override fun apply(upstream: Observable<T>): ObservableSource<T> {
        return upstream //.delay(5, TimeUnit.SECONDS)     //请求延迟五秒，再开始
            .subscribeOn(Schedulers.io())
            .unsubscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread(), true)
            .retryWhen(RetryWhenNetwork())
    }
}